<?php
include "header.php";
include "../dbase/db.php";
if(!empty($_POST['sub'])){
    $author=$_POST['author'];
    $title=$_POST['title'];
    $catagory=$_POST['catagory'];
    $copyright=$_POST['copyright'];
    $content=$_POST['content'];
    $addtime=date("Y-m-d h:i:s",time());
    $sql=mysql_query("insert into artical (title,author,catagory,copyright,content,addtime) VALUES ('$title','$author','$catagory','$copyright','$content','$addtime')");
    if($sql){
        $f=<<<f
            <script>
                alert("插入成功");
            </script>
f;
        echo $f;

    }else{
        echo "插入失败";
    }
}
?>
<style>
    form{line-height: 35px;}
</style>
<div>
    <form action="" method="post">
        <label>标题:</label>
        <input type="text" name="title">
        <br/>
        <label>作者:</label>
        <input type="text" name="author">
        <br/>
        <label>栏目:</label>
        <select name="catagory">
            <?php
            $sql1=mysql_query("select * from catagory");
            while($a=mysql_fetch_assoc($sql1)){
                echo "<option value='".$a['id']."'>".$a['catname']."</option>";
            }
            ?>
        </select>
        <br/>
        <label>版权:</label>
        <input type="text" name="copyright">
        <br/>
        <label>内容:</label>
        <textarea name="content" cols="30" rows="5">

        </textarea>
        <br/>
        <input type="submit" name="sub">
    </form>
</div>
